package test.com.sms.selenium.singlepoint.util;

import java.util.Set;

import org.openqa.selenium.By;

import test.com.sms.selenium.framework.SeleniumPageUtil;
import test.com.sms.selenium.util.SeleniumUtil;

public class SpContractsQuoterItemsAdvSearchPageUtil extends SeleniumPageUtil {
	public final static By CQA_SPAN_HEAD = By.id("lblHdr");
	public final static By CQA_TD_ITEMS = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[1]/tbody/tr/td[2]");
	public final static By CQA_TD_ITEM_TYPE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[2]");
	public final static By CQA_CHECKBOX_MSIC = By.id("ctl04_chkItemTypeMisc");
	public final static By CQA_LABEL_MSIC = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[3]/label[1]");
	public final static By CQA_CHECKBOX_GOOD = By.id("ctl04_chkItemTypeFG");
	public final static By CQA_LABEL_GOOD = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[3]/label[2]");
	public final static By CQA_TD_TOP_LEVEL = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[4]");
	public final static By CQA_CHECKBOX_TOP_LEVEL = By.id("ctl04_chkTopLevel");
	public final static By CQA_TD_QUOTABLE = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[1]/td[6]");
	public final static By CQA_CHECKBOX_QUOTABLE = By.id("ctl04_chkQuotable");
	public final static By CQA_RADIO_AND = By.id("ctl04_rdoCritAnd");
	public final static By CQA_LABEL_AND = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[2]/td[1]/label");
	public final static By CQA_TD_ITEM_ID = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[2]/td[2]");
	public final static By CQA_INPUT_ITEM_ID = By.id("ctl04_txtItemID");
	public final static By CQA_TD_ITEM_CID = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[2]/td[4]");
	public final static By CQA_SELECT_ITEM_CID = By.id("ctl04_cboItemClassKey");
	public final static By CQA_RADIO_OR = By.id("ctl04_rdoCritOr");
	public final static By CQA_LABEL_OR = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[3]/td[1]/label");
	public final static By CQA_TD_ITEM_DESC = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[3]/td[2]");
	public final static By CQA_INPUT_ITEM_DESC = By.id("ctl04_txtDescription");
	public final static By CQA_TD_ITEM_MFG = By.xpath("//*[@id='form1']/table/tbody/tr[2]/td/div/table[2]/tbody/tr[3]/td[4]");
	public final static By CQA_BTN_SEARCH = By.id("ctl04_btnSearch");
	public final static By CQA_BTN_CLEAR = By.id("ctl04_btnClear");
	public final static By CQA_BTN_CLOSE = By.id("ctl04_btnClose");
	
	public static void enter(){
		SpContractsQuoterPageUtil.enter();
		SpContractsQuoterPageUtil.displayHidenMenus(new By[]{SpContractsQuoterPageUtil.STQ_LINK_ITEM});
		SeleniumUtil.waitOnElements(new By[]{SpContractsQuoterPageUtil.STQ_LINK_ITEM_SEARCH});
		Set<String> befored = SeleniumUtil.getWindowHandles();
		SeleniumUtil.click(SeleniumUtil.getCachedElement(SpContractsQuoterPageUtil.STQ_LINK_ITEM_SEARCH));
		SeleniumUtil.waitForFixedMilliseconds(4000);
		SeleniumUtil.switchToPromptedWindow(befored, SeleniumUtil.getWindowHandles());
		waitForPageToLoad();
	}

	private static void waitForPageToLoad() {
		SeleniumUtil.selectDefaultContent();
		SeleniumUtil.waitOnElements(new By[]{
				CQA_SPAN_HEAD,CQA_SELECT_ITEM_CID,CQA_BTN_CLOSE
		});
	}
}
